package main

import "fmt"

//回调函数
type operation func(n1, n2 int) int

func test(n1 int, n2 int, callback operation) (n3 int) {

	n3 = callback(n1, n2)

	return
}

func callback(n1, n2 int) (n3 int) {

	n3 = n1 + n2
	return
}

func main() {

	fmt.Println(test(1, 2, callback))

	//匿名函数
	fmt.Println(test(100, 2, func(n1, n2 int) (n3 int) {

		n3 = n1 / n2
		return
	}))

}
